package Server;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.mysql.jdbc.Connection;

public class MyQuestionnare 
{

/**
 	 * function insert data to questionnare table
	 * @param con2 the connection to DB
	 * @param str string from gui
	 * @return int array to view the questionnare qui
 */
	public static void func(Connection con2, String[] str) 
	{

			
			String sql="INSERT INTO questionnare VALUES("+str[2]+","+str[1]+","+str[3]+","+str[4]+","+str[5]+","+str[6]+","+str[7]+","+str[8]+")";
			System.out.println(sql);
			Statement stmt;
			try {
				
			stmt = con2.createStatement();			
			stmt.executeUpdate(sql);
			stmt.close();		
			
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}	
		
			/**   insert data to survey table			*/
			if(str[2].toCharArray()[0]=='1')
			{
	
				
				sql="INSERT INTO survey VALUES("+str[1]+",0)";
				try {					
					stmt = con2.createStatement();			
					stmt.executeUpdate(sql);
					stmt.close();		
					
					} catch (SQLException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}	
			}
			
		
			
		
		
			}	
	
}
